import {ReturnValueHandler} from "../../../web/_ReturnValueHandler"
import {Component} from "../../anno/Component"
import {Order} from "../../anno/Order"


@Component()
@Order(-1)
class DefaultObjectHandler extends ReturnValueHandler{
  canWrite(value: any): boolean {
    const isObjectType = typeof value === "object" && value !== null
    return isObjectType
  }

  write(req: HttpRequest, res: HttpResponse, value: any): void {
    if (!res.closed()){
      res.end(value)
    }
  }

}
